let obj = {}

// e 支付类型
// k 已存在数据
let payconobj = (e, k) => {
	obj = {}
	switch (e) {
		case 1: // 微信支付
			obj = {
				app_id: '',
				mch_id: '',
				key: '',
				serial: '',
				cert_path: '',
				key_path: '',
				v3_key: '',
				platform_serial: '',
				platform_path: '',
				platform_update_time: '',
				to_balance: 0,
				to_batches: 0,
			}
			break
		case 2: // 支付宝支付
			obj = {
				app_id: '',
				pid: '',
				private_key_path: '',
				ali_public_key_path: '',
				ali_root_cert_path: '',
				app_public_key_path: '',
				aes_key: '',
				to_balance: 0,
			}
			break
		case 3: // 通联支付
			obj = {
				app_id: '',
				mch_id: '',
				private_key: '',
				public_key: '',
				sm2_private_key: '',
				sm2_public_key: '',
				test: false,
			}
			break
		case 4: // 京东收银
			obj = {
				app_id: '',
				agentNum: '',
				customerNum: '',
				shopNum: '',
				accessKey: '',
				secretKey: '',
				bill_account: '',
			}
			break
		case 5: // 会员支付
			obj = {
				app_id: '',
				appSecret: '',
				baseUrl: '',
				callbackUrl: '',
			}
	}

	if (k != undefined) {
		for (let ime in obj) {
			obj[ime] = k[ime]
		}
	}
	return obj
}

// 验证是否所有字段都填写完毕
// e 主体信息
// k 配置信息
let verify = (e, k) => {	
	let payobj = {
		app_id: '',
		payee_type: '',
		sp_name: '',
		status: '',
		title: '',
		ico:''
	}

	if (e.sp_id != undefined) {
		payobj.sp_id = e.sp_id
	}

	if (e.payee_type == 1 || e.payee_type == 3) {
		payobj.mch_id = ''
	}

	for (let ime in payobj) {
		if (e[ime] == '') {
			// 存在部分未填写数据
			return true
		}
		payobj[ime] = e[ime]
	}

	payobj.content = {}
	if (e.payee_type == 5) {
		k.appId = e.app_id
		
		for (let ime in k) {
			payobj.content[ime] = k[ime]
		}
	}

	k.app_id = e.app_id
	if (e.payee_type == 1 || e.payee_type == 3) {
		k.mch_id = e.mch_id
	}
	// 京东收银
	if (payobj.payee_type == 4) {
		if (k.accessKey == '' || k.secretKey == '') {
			// 存在部分未填写数据
			return true
		}
		for (let ime in k) {
			payobj.content[ime] = k[ime]
		}
	} else {
		for (let ime in k) {
			if (
				k[ime] == ''
				&& ime != 'platform_update_time'
				&& ime != 'to_balance'
				&& ime != 'to_batches'
				&& ime != 'aes_key'
				&& ime != 'serial'
				&& ime != 'platform_path'
				&& ime != 'platform_serial'
				&& ime != 'v3_key'
			) {
				// 存在部分未填写数据
				return true
			}
			payobj.content[ime] = k[ime]
		}
	}




	return payobj
}

export default {
	payconobj,
	verify
}